import { defineStore } from "pinia";
import { $endApi } from "@/api/base/index";

export const useUserStore = defineStore('user', {
  // 静态数据
  state: () => ({
    tenantId: '',
    token: null,
    userType: '',
  }),
  // 相当于计算属性(有数据缓存)
  getters: {},
  // actions即可以是同步函数也可以是异步函数
  actions: {
    // 获取管网漏损分析
    async login(data) {
        this.tenantId = data?.tenantId;
        this.token = data?.token;
        this.userType = data?.userType;
    },
  },
  // 开启数据缓存
  persist: {
    enabled: true,
    strategies: [
      {
        storage: sessionStorage,
      },
    ],
  },
});
